<template>
	<view class="page">
		<patient @info="getPatientId"></patient>
		<view class="prescription_list" v-if="list.length">
			<view class="card prescription_item" v-for="item in list" :key="item.id"
				@click="gotoPage(`/pagesCommon/prescription/prescriptionDetails?id=${item.id}`)">
				<doctorInfo :item="{
							name:detail.doctorName,
							titleName:detail.titleName,
							departName:detail.departName,
							levelName:detail.levelName,
							hospitalName:detail.hospitalName
						}"></doctorInfo>
				<view class="item_text">
					<view class="title">
						处方编号:
					</view>
					<view class="text">
						{{item.no}}
					</view>
				</view>
				<view class="item_text">
					<view class="title">
						诊断结果:
					</view>
					<view class="content ellipsis-2">
						{{item.diagnosis}}
					</view>
				</view>
				<view class="item_more">
					<view class="date">
						{{$getDate(item.createTime)}}
					</view>
					<view class="more" @click="gotoPage(`/pagesCommon/prescription/prescriptionDetails?id=${item.id}`)">
						查看详情
						<uni-icons class="icon" type="right" size="12" color="#999"></uni-icons>
					</view>
				</view>
			</view>
		</view>
		<view class="no_thing" v-else>
			<image class="placeholder" src="@/static/images/noting.png" mode="scaleToFill"></image>
		</view>
	</view>
</template>

<script>
	import {
		queryPrescriptionInfoList
	} from '@/api/index.js'
	export default {
		name: 'prescriptionList',
		data() {
			return {
				list: [],
				total: 0,
				queryForm: {
					pageNo: 1,
					pageSize: 10,
					id: 0
				}
			}
		},
		onLoad() {
			// this.queryPrescriptionInfoList()
		},

		methods: {
			getPatientId(value) {
				this.queryForm.id = value.id
				this.queryPrescriptionInfoList()
			},
			queryPrescriptionInfoList() {
				queryPrescriptionInfoList(this.queryForm).then(res => {
					this.list = res.data.list
					this.total = res.total
				})
			},
			gotoPage(url) {
				if (!url) return
				uni.navigateTo({
					url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.prescription_list {
		.prescription_item {
			margin: 30rpx 0;

			.item_text {
				margin-bottom: 30rpx;
				display: flex;
				align-items: flex-start;
				font-size: 28rpx;

				.title {
					flex: 0 0 120rpx;
					color: #999999;
				}

				.text {
					margin-left: 20rpx;
				}

				.content {
					margin-left: 20rpx;
					background: #F8FAFB;
					border-radius: 10rpx;
					padding: 20rpx 10rpx;
				}
			}

			.item_more {
				display: flex;
				align-items: center;
				justify-content: space-between;
				font-size: 26rpx;
				color: #999999;
			}
		}
	}
</style>